import { createStore } from 'vuex'

const store = createStore({
  state: {
    isConnected: false,//连接状态
  },
  mutations: {
    setConnected(state: any, isConnected: boolean) {
      state.isConnected = isConnected
    },
  },
  actions: {
    connect({ commit }: { commit: any }) {
      // 连接成功后，将 isConnected 状态设置为 true
      commit('setConnected', true)
    },
    disconnect({ commit }: { commit: any }) {
      // 断开连接或退出登录时，将 isConnected 状态设置为 false
      commit('setConnected', false)
    }
  }
})


export default store